<?php

namespace Modules\Xunsearch\Library;

use Modules\Queue\Models\Queue;

class Task
{
    public static function xunsearchRebuild(Queue $queue)
    {
        $queue->isRun();
        $data = objectToArray($queue->data);
        $total = count($data);
        $i = 1;
        foreach ($data as $item) {
            $queue->percentage($i, $total, '正在重建' . $item . '项目索引');
            $i++;
            $xunsearch = new Xunsearch($item);
            $xunsearch->rebuild($queue);
        }
        return true;
    }
}